package com.xbn.xbnmall.cart.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

/**
 * @author XBN
 * @date 2020/8/13 12:23
 * @email 78742541@qq.com
 */
@EnableRedisHttpSession
@Configuration
public class XbnmallSessionConfig {

    /*设置springSession的redis序列化*/
    @Bean
    public RedisSerializer<Object> springSessionDefaultRedisSerializer() {
        return new GenericJackson2JsonRedisSerializer();
    }
    /*
    * 设置session cookie
    * */
    @Bean
    public CookieSerializer cookieSerializer(){
            DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
            cookieSerializer.setDomainName("xbnmall.com");
            cookieSerializer.setCookieName("XBNSESSION");

            return cookieSerializer;
        }

}
